package com.pcbly.web.action.sms;

import com.pcbly.web.action.BaseAction;
import com.pcbly.web.bean.sms.SmsConfigBean;
import com.pcbly.web.business.sms.SmsConfigService;

public class SmsConfigAction extends BaseAction<SmsConfigBean> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8582362019368918037L;
	
	protected SmsConfigService smsService; 
	
	public void setSmsConfigService(SmsConfigService smsService) {
		this.smsService = smsService;
	}
	private SmsConfigBean sms;
	
	
	public SmsConfigBean getSmsConfig() {
		return sms;
	}

	public void setSmsConfig(SmsConfigBean sms) {
		this.sms = sms;
	}
	public String view() throws Exception {
		sms=smsService.getSmsConfigBeanById(getId());
		return super.view();
	}
	public String update() throws Exception {
		sms=smsService.getSmsConfigBeanById(getId());
		return super.update();
	}
	public String index() throws Exception {
		return super.index();
	}
	public String add() throws Exception { 
		return super.add();
	}
	public String save() throws Exception {
		if (log.isDebugEnabled()) {
			log.debug("login save..........");
			log.debug(sms.getId());
		}
		try{
		if (sms.getId() == null || "".equals(sms.getId())) {// new 
			smsService.saveSmsConfigBean(sms);
			addActionMessage(getText("entity.saved"));
		} else {// update
			smsService.updateSmsConfigBean(sms);
			addActionMessage(getText("entity.updated"));
		}}catch(Exception e){
			e.printStackTrace();
		}
		return super.save();
	}
	public String dwrSave(SmsConfigBean bean) throws Exception {
		if (log.isDebugEnabled()) {
			log.debug("login save..........");
			log.debug(bean.getId());
		}
		try{
		if (bean.getId() == null || "".equals(bean.getId())) {// new 
			smsService.saveSmsConfigBean(bean);
		} else {// update
			smsService.updateSmsConfigBean(bean);
		}}catch(Exception e){
			e.printStackTrace();
		}
		return super.dwrBaseSave(bean.getId());
	}
	public String delete() throws Exception {
		if (log.isDebugEnabled()) {
			log.debug("login delete..........");
			log.debug(getId());
		}
		if(getId().indexOf(",")>=0){
			smsService.removeSmsConfigBeanByIds(getId());
		}else{
			smsService.removeSmsConfigBeanById(getId());
		}
		return super.delete();
	}
	public String dwrDelete(String id) throws Exception {
		if (log.isDebugEnabled()) {
			log.debug("login delete..........");
			log.debug(id);
		}
		if(id.indexOf(",")>=0){
			smsService.removeSmsConfigBeanByIds(id);
		}else{
			smsService.removeSmsConfigBeanById(id);
		}
		return super.dwrBaseDelete(id);
	}
	
}